﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
    xmlns:southridge="clr-namespace:Southridge.Controls;assembly=Southridge.Controls"
    xmlns:Converter="clr-namespace:Co9320.NamaAlert.Converter"
    xmlns:me="clr-namespace:Co9320.NamaAlert"
    xmlns:ViewModel="clr-namespace:Co9320.NamaAlert.ViewModel">

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    <Converter:BooleanToVisibilityNegationConverter x:Key="BooleanToVisibilityNegationConverter"/>

    <ContextMenu x:Key="ProgramsRowContextMenu">
        <MenuItem Header="生放送のページへ移動" 
                  Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.OpenUriCommand}" 
                  CommandParameter="{Binding Uri}"
                  Visibility="{Binding Path=IsOnAir, Converter={StaticResource BooleanToVisibilityConverter}}">
            <MenuItem.Icon>
                <Image Source="Images/browser_small.png" Style="{StaticResource SmallIconStyle}" />
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Header="放送局のページへ移動" 
                  Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.OpenUriCommand}" 
                  CommandParameter="{Binding Station.Uri}">
            <MenuItem.Icon>
                <Image Source="Images/browser_small.png" Style="{StaticResource SmallIconStyle}" />
            </MenuItem.Icon>
        </MenuItem>
        <Separator />
        <MenuItem Header="生放送のURLをコピー" 
                  Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.CopyUriCommand}" 
                  CommandParameter="{Binding Uri}"
                  Visibility="{Binding Path=IsOnAir, Converter={StaticResource BooleanToVisibilityConverter}}">
            <MenuItem.Icon>
                <Image Source="Images/copy_small.png" Style="{StaticResource SmallIconStyle}" />
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Header="放送局のURLをコピー" 
                  Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.CopyUriCommand}" 
                  CommandParameter="{Binding Uri}"
                  Visibility="{Binding Path=IsOnAir, Converter={StaticResource BooleanToVisibilityConverter}}">
            <MenuItem.Icon>
                <Image Source="Images/copy_small.png" Style="{StaticResource SmallIconStyle}" />
            </MenuItem.Icon>
        </MenuItem>
        <Separator />
        <MenuItem Header="通知対象に追加" 
                  Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.AddAlertTargetCommand}" 
                  CommandParameter="{Binding Station}"
                  Visibility="{Binding Path=Station.IsAlertTarget, Converter={StaticResource BooleanToVisibilityNegationConverter}}">
            <MenuItem.Icon>
                <Image Source="Images/bell-plus_small.png" Style="{StaticResource SmallIconStyle}" />
            </MenuItem.Icon>
        </MenuItem>
        <MenuItem Header="通知対象から削除" 
                  Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.DeleteAlertTargetCommand}" 
                  CommandParameter="{Binding Station.IsAlertTarget}"
                  Visibility="{Binding Path=Station.IsAlertTarget, Converter={StaticResource BooleanToVisibilityConverter}}">
            <!--<MenuItem.Icon>
                <Image Source="Images/bell-plus_small.png" Style="{StaticResource SmallIconStyle}" />
            </MenuItem.Icon>-->
        </MenuItem>
    </ContextMenu>

    <!--<DataTemplate x:Key="AlertTargetCellTemplate">
        <Image>
            <Image.Style>
                <Style TargetType="{x:Type Image}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding}" Value="True">
                            <Setter Property="Source"  Value="Images/bell_small.png" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Image.Style>
        </Image>
    </DataTemplate>-->

    <DataTemplate x:Key="AlertSettingsCellTemplate">
        <StackPanel Orientation="Horizontal"
                    DataContext="{Binding}"
                    Visibility="{Binding Path=IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}">
            <Image Source="Images/window_small.png" 
                   Style="{StaticResource SmallIconStyle}"
                   Visibility="{Binding Path=AlertByWindow, Converter={StaticResource BooleanToVisibilityConverter}}"
                   Margin="1" />
            <Image Source="Images/balloon_small.png" 
                   Style="{StaticResource SmallIconStyle}"
                   Visibility="{Binding Path=AlertByBalloon, Converter={StaticResource BooleanToVisibilityConverter}}"
                   Margin="1" />
            <Image Source="Images/browser_small.png" 
                   Style="{StaticResource SmallIconStyle}"
                   Visibility="{Binding Path=AlertByBrowser, Converter={StaticResource BooleanToVisibilityConverter}}"
                   Margin="1" />
            <Image Source="Images/mail_small.png" 
                   Style="{StaticResource SmallIconStyle}"
                   Visibility="{Binding Path=AlertByMail, Converter={StaticResource BooleanToVisibilityConverter}}"
                   Margin="1" />
            <Image Source="Images/sound_small.png"
                   Style="{StaticResource SmallIconStyle}"
                   Visibility="{Binding Path=AlertBySound, Converter={StaticResource BooleanToVisibilityConverter}}"
                   Margin="1" />            
        </StackPanel>

    </DataTemplate>

    <xcdg:CellEditor x:Key="AlertSettingsCellEditor">
        <xcdg:CellEditor.EditTemplate>
            <DataTemplate>
                <Grid>
                    <!--<StackPanel Orientation="Horizontal"
                        DataContext="{Binding}"
                        Visibility="{Binding Path=IsEnabled, Converter={StaticResource BooleanToVisibilityNegationConverter}}">
                        <Button Style="{StaticResource ImageButtonStyle}" 
                                Command="">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="Images/bell-plus_small.png"
                                       Style="{StaticResource SmallIconStyle}"
                                       VerticalAlignment="Center"
                                       Margin="1" />
                                <TextBlock Text="追加" VerticalAlignment="Center" />
                            </StackPanel>
                        </Button>
                    </StackPanel>-->

                    <StackPanel Orientation="Horizontal"
                                DataContext="{xcdg:CellEditorBinding}"
                                Visibility="{Binding Path=IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}">

                        <ToggleButton Style="{StaticResource ImageToggleButtonStyle}"
                                          IsChecked="{Binding AlertByWindow}">
                            <Grid ToolTip="通知ウィンドウ">
                                <Image Source="Images/window_small.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToggleButton}}, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"
                                       Margin="1" />
                                <Image Source="Images/window_small_disable.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToggleButton}}, Path=IsChecked, Converter={StaticResource BooleanToVisibilityNegationConverter}}"
                                       Margin="1" />
                            </Grid>
                        </ToggleButton>

                        <ToggleButton Style="{StaticResource ImageToggleButtonStyle}"
                                          IsChecked="{Binding AlertByBalloon}">
                            <Grid ToolTip="バルーン">
                                <Image Source="Images/balloon_small.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToggleButton}}, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"
                                       Margin="1" />
                                <Image Source="Images/balloon_small_disable.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToggleButton}}, Path=IsChecked, Converter={StaticResource BooleanToVisibilityNegationConverter}}"
                                       Margin="1" />
                            </Grid>
                        </ToggleButton>

                        <ToggleButton Style="{StaticResource ImageToggleButtonStyle}"
                                          IsChecked="{Binding AlertByBrowser}">
                            <Grid ToolTip="Web ブラウザー">
                                <Image Source="Images/browser_small.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToggleButton}}, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"
                                       Margin="1" />
                                <Image Source="Images/browser_small_disable.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToggleButton}}, Path=IsChecked, Converter={StaticResource BooleanToVisibilityNegationConverter}}"
                                       Margin="1" />
                            </Grid>
                        </ToggleButton>

                        <ToggleButton Style="{StaticResource ImageToggleButtonStyle}"
                                          IsChecked="{Binding AlertByMail}">
                            <Grid ToolTip="メール">
                                <Image Source="Images/mail_small.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToggleButton}}, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"
                                       Margin="1" />
                                <Image Source="Images/mail_small_disable.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ToggleButton}}, Path=IsChecked, Converter={StaticResource BooleanToVisibilityNegationConverter}}"
                                       Margin="1" />
                            </Grid>
                        </ToggleButton>

                        <me:DropDownButton 
                                      Style="{StaticResource DropDownButtonStyle}">
                            <me:DropDownButton.Content>
                                <Grid ToolTip="サウンド">
                                    <Image Source="Images/sound_small.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding Path=AlertBySound, Converter={StaticResource BooleanToVisibilityConverter}}"
                                       Margin="1" />
                                    <Image Source="Images/sound_small_disable.png" 
                                       Style="{StaticResource SmallIconStyle}"
                                       Visibility="{Binding Path=AlertBySound, Converter={StaticResource BooleanToVisibilityNegationConverter}}"
                                       Margin="1" />
                                </Grid>
                            </me:DropDownButton.Content>
                            <me:DropDownButton.DropDown>
                                <ContextMenu>
                                    <MenuItem Header="サウンドなし">
                                        <MenuItem.Icon>
                                            <Image Source="Images/delete_small.png" Style="{StaticResource SmallIconStyle}" />
                                        </MenuItem.Icon>
                                    </MenuItem>
                                    <Separator />
                                    <MenuItem Header="test.wav"/>
                                    <Separator />
                                    <MenuItem Header="設定..." />
                                </ContextMenu>
                            </me:DropDownButton.DropDown>
                        </me:DropDownButton>
                    </StackPanel>
                </Grid>
            </DataTemplate>
        </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>

    <!-- Icon -->
    <DataTemplate x:Key="StationIconCellTemplate">
        <Button DataContext="{Binding}"
                Padding="0" Style="{StaticResource ImageButtonStyle}"                
                Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.OpenUriCommand}"
                CommandParameter="{Binding Path=TargetUri}">
            <Image Source="{Binding Path=Icon}" Width="16" Height="16" />
        </Button>
    </DataTemplate>

    <!-- Title -->
    <DataTemplate x:Key="TitleCellTemplate">
        <StackPanel Orientation="Horizontal" DataContext="{Binding}">
            <Button Padding="0" Style="{StaticResource ImageButtonStyle}">
                <Image Source="Images/key_small.png" 
                       Style="{StaticResource SmallIconStyle}"
                       Visibility="{Binding Path=IsMemberOnly, Converter={StaticResource BooleanToVisibilityConverter}}"
                       Margin="1" />
            </Button>
            <Button Padding="0" Style="{StaticResource ImageButtonStyle}">
                <Image Source="Images/face_small.png" 
                       Style="{StaticResource SmallIconStyle}"
                       Visibility="{Binding Path=IsFace, Converter={StaticResource BooleanToVisibilityConverter}}"
                       Margin="1" />
            </Button>
            <TextBlock Text="{Binding Title}" />

        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="StartDateTimeCellTemplate">
        <TextBlock Text="{Binding StringFormat=HH:mm}" />
    </DataTemplate>

    <DataTemplate x:Key="ElapsedTimeCellTemplate">
        <TextBlock />
    </DataTemplate>

    <DataTemplate x:Key="VisitorCountCellTemplate">
        <TextBlock Text="{Binding}" 
                   TextAlignment="Right" 
                   HorizontalAlignment="Stretch" />
    </DataTemplate>

    <DataTemplate x:Key="CommentCountCellTemplate">
        <TextBlock Text="{Binding}" 
                   TextAlignment="Right" 
                   HorizontalAlignment="Stretch" />
    </DataTemplate>

    <DataTemplate x:Key="RatingCellTemplate">
        <southridge:RatingsControl RatingMaximum="5" Rating="{Binding Path=Rating}" />
    </DataTemplate>

    <xcdg:CellEditor x:Key="RatingCellEditor">
        <xcdg:CellEditor.EditTemplate>
            <DataTemplate>
                <southridge:RatingsControl RatingMaximum="5" DataContext="{xcdg:CellEditorBinding}" Rating="{Binding Path=Rating, Mode=TwoWay}" />
            </DataTemplate>
        </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>

    <DataTemplate x:Key="MemberOnlyCellTemplate">
        <Image Source="Images/key_small.png" 
               Margin="1">
            <Image.Style>
                <Style BasedOn="{StaticResource SmallIconStyle}" TargetType="{x:Type Image}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding}" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Image.Style>
        </Image>
    </DataTemplate>

    <DataTemplate x:Key="FaceCellTemplate">
        <Image Source="Images/face_small.png" 
               Margin="1">
            <Image.Style>
                <Style BasedOn="{StaticResource SmallIconStyle}" TargetType="{x:Type Image}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding}" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Image.Style>
        </Image>
    </DataTemplate>
    
</ResourceDictionary>
